//
//  GDBusStationController.m
//  GraduationDesign
//
//  Created by JiaKang.Zhong on 16/1/5.
//  Copyright © 2016年 JiaKang.Zhong. All rights reserved.
//

#import "GDBusStationController.h"
#import "GDBusStationStatsController.h"
#import "GDBusStationLineController.h"
#import "GDBusStationLocationController.h"
#import <UIImage+GIF.h>
#import <ImageIO/ImageIO.h>
@interface GDBusStationController ()
@property (weak, nonatomic) IBOutlet UIImageView *busLocationView;
@property (weak, nonatomic) IBOutlet UIImageView *busStationView;
@property (weak, nonatomic) IBOutlet UIImageView *busLineView;
@property (weak, nonatomic) IBOutlet UIImageView *headView;
@end

@implementation GDBusStationController

- (void)viewDidLoad {
    [super viewDidLoad];
  UIBarButtonItem *backToHomeItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"left-cross"] style:UIBarButtonItemStylePlain target:self action:@selector(backToHomeClick)];
//    UIBarButtonItem * backToHomeItem = [[UIBarButtonItem alloc] initWithTitle:@"<<<" style:UIBarButtonItemStylePlain target:self action:@selector(backToHomeClick)];
    self.navigationItem.leftBarButtonItem = backToHomeItem;

    [self.navigationController.navigationBar setTranslucent:NO];//设置navigationbar的半透明
    self.navigationItem.title = @"公交线路在手";//设置navigationbar上显示的标题
//    [self.navigationController.navigationBar setBarTintColor:[UIColor purpleColor]];//设置navigationbar的颜色

    
    self.busLineView.userInteractionEnabled = YES;
    self.busStationView.userInteractionEnabled = YES;
    self.busLocationView.userInteractionEnabled = YES;
    UITapGestureRecognizer * busLocationTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(gotoBusStationLocationController)];
    [self.busLocationView addGestureRecognizer:busLocationTap];
    UITapGestureRecognizer * busLineViewTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(gotoBusStationLineController)];
    [self.busLineView addGestureRecognizer:busLineViewTap];
    UITapGestureRecognizer * busStationViewTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(gotoBusStationController)];
    [self.busStationView addGestureRecognizer:busStationViewTap];

    //   当前城市为：
    UILabel * nowCity = [[UILabel alloc] initWithFrame:CGRectMake(GDScreenSize.size.width - 150, 5, 150, 30)];
    nowCity.text = [NSString stringWithFormat:@"当前城市为:%@",self.cityName];
    nowCity.textColor = [UIColor redColor];
    [self.view addSubview:nowCity];
    
    // gif图的播放
    NSString * gifFile = [[NSBundle mainBundle] pathForResource:@"bus_headView.gif" ofType:nil];
    self.headView.image = [UIImage sd_animatedGIFWithData: [NSData dataWithContentsOfFile:gifFile]];
}

- (void) backToHomeClick{
    [self dismissViewControllerAnimated:YES completion:nil];
}

-(void) gotoBusStationController{
    GDLog(@"%s",__func__);
    GDBusStationStatsController * busStatsController = [[GDBusStationStatsController alloc] init];
    busStatsController.cityName = self.cityName;
//    [self presentViewController:busStatsController animated:YES completion:nil];
    [self.navigationController pushViewController:busStatsController animated:YES];
}

-(void) gotoBusStationLineController{
        GDLog(@"%s",__func__);
    GDBusStationLineController * busStatsLineController = [[GDBusStationLineController alloc] init];
    busStatsLineController.cityName = self.cityName;
    [self.navigationController pushViewController:busStatsLineController animated:YES];
}

-(void) gotoBusStationLocationController{
        GDLog(@"%s",__func__);
    GDBusStationLocationController * busStatsLocationController = [[GDBusStationLocationController alloc] init];
    busStatsLocationController.cityName = self.cityName;
    busStatsLocationController.location = self.location;
   [self.navigationController pushViewController:busStatsLocationController animated:YES];
}


@end
